package Demo6;

import java.util.Scanner;

class List {
	int data;
	int pos;

	public List(int data, int pos) {
		this.data = data;
		this.pos = pos;
	}

	public List() {
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int len = s.nextInt();
		List[] list = new List[len];
		int[] space = new int[3];
		//空闲区个数
		for (int i = 0; i < list.length; i++) {
			int data1 = s.nextInt();
			int pos = i + 1;
			list[i] = new List(data1, pos);
		}
		for (int i = 0; i < space.length; i++) {
			space[i] = s.nextInt();
		}

		List list1;
		int pos = 0, j = 0;
		int task = 3;
		while (task > 0) {
			boolean flag = false;
			//每次装入完成后都进行一次冒泡排序
			for (int k = 0; k < list.length; k++) {
				for (int m = 0; m < list.length - k - 1; m++) {
					if (list[m].data > list[m + 1].data) {
						list1 = list[m];
						list[m] = list[m + 1];
						list[m + 1] = list1;
					}
				}
			}
			for (List value : list) {
				if (space[j] <= value.data) {
					value.data -= space[j];
					pos = value.pos;
					flag = true;
					break;
				}
			}
			if (!flag) {
				System.out.print("false ");
			} else {
				System.out.print(pos + " ");
			}
			task--;
			j++;
		}
	}
}


